﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="CountryList.aspx.cs" Inherits="Omabar.CMS.CMS.CountryList" %>

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <link rel="stylesheet" type="text/css" href="../CSS/bootstrap_min.css" media="all" />
    <link rel="stylesheet" type="text/css" href="../CSS/bootstrap_responsive_min.css" media="all" />
    <link rel="stylesheet" type="text/css" href="../CSS/Style.css" media="all" />
    <link rel="stylesheet" type="text/css" href="../CSS/todc_bootstrap.css" media="all" />
    <link rel="stylesheet" type="text/css" href="../CSS/Themes.css" media="all" />
    <link rel="stylesheet" type="text/css" href="../CSS/inside.css" media="all" />
    <script type="text/javascript" src="../JavaScript/jquery.1.8.3.js"></script>
    <script type="text/javascript" src="../JavaScript/jquery.cookie.js"></script>
    <script type="text/javascript" src="../JavaScript/bootstrap.js"></script>
    <script type="text/javascript" src="../JavaScript/inside.js"></script>
    <title>国家列表</title>
    <link rel="shortcut icon" href="favicon.ico" />
    <!--[if IE 7]><link href="../CSS/font_awesome_ie7.css" rel="stylesheet" /><![endif]-->
    <!--[if lte IE 9]><script src="../JavaScript/watermark.js"></script><![endif]-->
</head>
<body>
    <div id="main">
        <div class="container-fluid">
            <div class="row-fluid">
                <div class="span12">
                    <div class="box">
                        <div class="box-title">
                            <div class="span8">
                                <h3><i class="icon-table"></i>国家列表</h3>
                            </div>
                            <div class="span4">
                                <div class="form-horizontal">
                                    <input type="text" id="keyword-input" class="input-small-z" value="" placeholder="请输入关键词" />
                                    <button class="btn" id="btn_search">查询</button>
                                </div>
                            </div>
                        </div>

                        <div class="box-content nozypadding">
                            <div class="row-fluid">
                                <div class="span8 control-group">
                                    <div class="span5">
                                        <a class="btn" href="CountryAdd.aspx"><i class="icon-plus"></i>添加</a>
                                        <a class="btn" href="javascript:location.href='CountryList.aspx';"><i class="icon-refresh"></i></a>
                                    </div>

                                    <div class="span4 datatabletool">
                                        <div class="btn-group">
                                            <a class="btn" attr="BatchDel" title="删除"><i class="icon-trash"></i></a>
                                        </div>
                                    </div>
                                </div>
                            </div>

                            <div class="row-fluid dataTables_wrapper">
                                <form method="post" id="listForm">
                                    <table id="listTable" class="table table-hover table-nomargin table-bordered usertable dataTable">
                                        <thead>
                                            <tr>
                                                <th class='with-checkbox'>
                                                    <input type="checkbox" class="check_all" />
                                                </th>
                                                <th>国家名称</th>
                                                <th>所属大洲</th>
                                                <th>操作</th>
                                            </tr>
                                        </thead>
                                        <tbody>
                                            <%foreach (var country in countries)
                                              { %>
                                            <tr>
                                                <td class="with-checkbox">
                                                    <input type="checkbox" name="check" value="<%=country.COUNTRY_ID%>" />
                                                </td>
                                                <td><%=country.COUNTRY_NAME%></td>
                                                <td><%=country.BELONG%></td>
                                                <td class='hidden-480'>
                                                    <a href="#" style="display: none;" class="btn" rel="tooltip" title="View"><i class="icon-search"></i></a>
                                                    <a href="CountryEdit.aspx?id=<%=country.COUNTRY_ID%>" class="btn" rel="tooltip" title="编辑"><i class="icon-edit"></i></a>
                                                    <a href="javascript:void(0);" class="btn" rel="tooltip" title="Delete" attr="delopt_<%=country.COUNTRY_ID%>"><i class="icon-remove"></i></a>
                                                </td>
                                            </tr>
                                            <%}%>
                                        </tbody>
                                    </table>
                                    <!--分页-->
                                    <%if(pageCount>1){%>
                                    <div class="dataTables_paginate paging_full_numbers">
                                        <span>
                                            <a href="CountryList.aspx?keywords=<%=keywords%>&pageno=1">首页</a> 
                                            <%if(pageNo>1) {%>
                                            <a href="CountryList.aspx?keywords=<%=keywords%>&pageno=<%=pageNo-1%>">上一页</a> 
                                            <%}%>

                                            <%for(int i=(groupNo-1)*10+1;i<pageNo;i++){ %>
                                            <a href="CountryList.aspx?keywords=<%=keywords%>&pageno=<%=i%>"><%=i%></a>
                                            <%}%>
                                            
                                            <a class="paginate_active"><%=pageNo%></a> 

                                            <%if(pageNo<groupNo*10) {%>
                                            <%for(var j=pageNo+1;j<=groupNo*10;j++){%>
                                            <%if (j > pageCount) break; %>
                                            <a href="CountryList.aspx?keywords=<%=keywords%>&pageno=<%=j%>"><%=j%></a>
                                            <%}%>
                                            <%}%>

                                            <%if(groupNo*10<pageCount){%>
                                            ...
                                            <%}%>

                                            <%if(pageNo<pageCount){ %>
                                            <a href="CountryList.aspx?keywords=<%=keywords%>&pageno=<%=pageNo+1%>">下一页</a>
                                            <%}%>
                                            <a href="CountryList.aspx?keywords=<%=keywords%>&pageno=<%=pageCount%>">末页</a>
                                        </span>
                                    </div>
                                    <%}%>
                                </form>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <script>
        $(function () {
            var delOpt = function (event) {
                if (confirm("您确定要删除吗?")) {
                    $.post('../Handler/CountryDelete.ashx?batch=false', { id: event.data.id }, function (data) {
                        if (data.Success) {
                            location.reload();
                        } else {
                            alert(data.Tip);
                        }
                    }, 'json');
                }
            };

            $("a[attr^='delopt_']").each(function () {
                var tmp = $(this).attr('attr').split('_');
                $(this).bind("click", { id: tmp[1] }, delOpt);
            });

            $("[attr='BatchDel']").click(function () {
                var check = $("input:checked");
                if (check.length < 1) {
                    alert('请选择删除项');
                    return false;
                }
                var ids = new Array();
                check.each(function (i) {
                    ids[i] = $(this).val();
                });

                $.post('../Handler/CountryDelete.ashx?batch=true', { ids: ids }, function (data) {
                    if (data.Success) {
                        location.reload();
                    } else {
                        alert(data.Tip);
                    }
                }, 'json');
            });

            $("#btn_search").click(function () {
                var keywords = $.trim($('#keyword-input').val());
                if (keywords.length <= 0) {
                    alert('请输入搜索关键字.');
                    $('#keyword-input').focus();
                    return false;
                }
                window.location.href = 'CountryList.aspx?keywords=' + keywords;
            });

            $("#keyword-input").keyup(function (e) {
                if (e.keyCode == 13) {
                    $("#btn_search").click();
                    return false;
                }
            });
        });
    </script>
</body>
</html>
